<?php
/*
*
* 零起飞企业管理系统（07FLY-ESM）
*
* ----------------------------------------------
* 零起飞网络 - 专注于企业管理系统开发
* 以质量求生存，以服务谋发展，以信誉创品牌 !
* ----------------------------------------------
* @copyright	Copyright (C) 2017-2018 07FLY Network Technology Co,LTD All rights reserved.
* @license    For licensing, see LICENSE.html
* @author ：kfrs <goodkfrs@QQ.com> 574249366
* @version ：1.0
* @link ：http://www.07fly.xyz
*/

namespace app\workflow\controller;

/**
 * 报销单列表管理-控制器
 */
class OaReimburse extends WorkflowBase
{

	/**
	 * 报销单列表列表=》模板
	 * @return mixed|string
	 */
	public function show()
	{
		$this->common_data();
		return $this->fetch('show');
	}

	/**
	 * 报销单列表列表-》json数据
	 * @return
	 */
	public function show_json()
	{

		$where = $this->logicOaReimburse->getWhere($this->param);
		$orderby = $this->logicOaReimburse->getOrderby($this->param);
		$list = $this->logicOaReimburse->getOaReimburseList($where, true, $orderby);
		return $list;
	}


	/**
	 * 报销单列表添加
	 * @return mixed|string
	 */
	public function add()
	{

		IS_POST && $this->jump($this->logicOaReimburse->oaReimburseAdd($this->param));
		$this->common_data();
		return $this->fetch('add');
	}

	/**
	 * 报销单列表编辑
	 * @return mixed|string
	 */

	public function edit()
	{

		IS_POST && $this->jump($this->logicOaReimburse->oaReimburseEdit($this->param));

		$info = $this->logicOaReimburse->getOaReimburseInfo(['id' => $this->param['id']]);
		$this->assign('info', $info);
		$this->common_data();
		return $this->fetch('edit');
	}

	/**
	 * 报销单列表=>审核
	 * @return mixed|string
	 */

	public function audit()
	{

		IS_POST && $this->jump($this->logicOaReimburse->oaReimburseAudit($this->param));
		$info = $this->logicOaReimburse->getOaReimburseInfo(['id' => $this->param['id']]);
		$this->assign('info', $info);
		$this->common_data();
		return $this->fetch('audit');

	}

	/**
	 * 报销单列表删除
	 */
	public function del()
	{
		$this->jump($this->logicOaReimburse->oaReimburseDel($this->param));
	}


	/**
	 * 报销单列表=>详细
	 * @return mixed|string
	 */

	public function detail()
	{
		$info = $this->logicOaReimburse->getOaReimburseInfo(['id' => $this->param['id']]);
		$workflow = $this->logicWorkflowBusinessHistory->getWorkflowBusinessHistoryLog(['business_id' => $this->param['id'], 'business_type' => 'oa_reimburse']);
		$this->assign('info', $info);
		$this->assign('workflow', $workflow);
		$this->common_data();
		return $this->fetch('detail');
	}


    /**
     * 提交审批
     */
    public function audit_send()
    {
        IS_POST && $this->jump($this->logicOaReimburse->setAuditSend($this->param));

        //内部接口调用=》提交看审批
        $postdata['business_type'] = 'oa_reimburse';
        $rpcurl = url('workflow/rpc.RpcApi/getWorkFlowList',$postdata);
        $res = httpRpc($rpcurl);
        $audit_workflow_list = [];
        if ($res['code'] == 1) {
            $audit_workflow_list = $res['data'];
        }
        $this->assign('id', $this->param['id']);
        $this->assign('audit_workflow_list', $audit_workflow_list);

        return $this->fetch('audit_send');

    }

    /**
     * 取消审核
     */
    public function audit_cancel()
    {
        $this->jump($this->logicOaReimburse->setAuditCancel($this->param));
    }

    /**
     * 审核详细
     */
    public function audit_detail()
    {
        $intedata['business_type'] = 'oa_reimburse';
        $intedata['business_id'] = $this->param['id'];
        //内部接口调用=》提交看审批
        $rpcurl = url('workflow/rpc.RpcApi/getWorkflowBusinessInfo', $intedata);
        $res = httpRpc($rpcurl);
        $this->assign('info', $res['data']);
        return $this->fetch('audit_detail');
    }


	/**
	 * 审批详细
	 */
	public function approval()
	{
		IS_POST && $this->jump($this->logicWorkflowBusiness->workflowBusinessApproval($this->param));
		$info = $this->logicOaReimburse->getOaReimburseInfo(['id' => $this->param['id']]);
		$wfinfo = $this->logicWorkflowBusinessHistory->getWorkflowBusinessHistoryInfo(['id' => $this->param['wbhid']]);
		$this->assign('info', $info);//业务信息
		$this->assign('wfinfo', $wfinfo);//业务审核信息
		$this->common_data();
		return $this->fetch('approval');
	}


	/**公共数据
	 * Author: 开发人生 goodkfrs@qq.com
	 * Date: 2021/7/5 0005 11:09
	 */
	public function common_data()
	{
		$type_list = $this->logicOaReimburse->getOaReimburseType();
		$this->assign('type_list', $type_list);

		$sys_user = $this->logicSysUser->getSysUserSubList();
		$this->assign('sys_user_list', $sys_user);
		$this->assign('sys_user_id', SYS_USER_ID);

		$status_list = $this->logicOaReimburse->getStatus();
		$this->assign('status_list', $status_list);

	}

}
